package com.yutel.tool.web;

public class WebCmd {
	public static final String TYPE_WEB = "web";

	public static void command(String[] args) throws Exception {
		String type = args[0];
		String thread = null;
		String url = null;
		if (args.length > 1) {
			thread = args[1];
		}
		if (args.length > 2) {
			url = args[2];
		}
		if (type.equals(TYPE_WEB)) {
			start(thread, url);
		} else {
			System.out.println(args + "is not support command");
			System.out.println(help());
		}
	}

	public static void start(String thread, String url) {
		int count = 0;
		try {
			count = Integer.parseInt(thread);
		} catch (NumberFormatException e) {
		}
		for (int i = 0; i < count; i++) {
			WebThread wt = new WebThread(url);
			wt.start();
		}
	}

	public static String help() {
		StringBuffer sb = new StringBuffer();
		sb.append("测试:\tjava -jar spanner.jar web <thread> <url>").append("\n");
		return sb.toString();
	}

}
